package com.akita.spring.ai.entity.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.ai.chat.messages.Message;

import java.util.Objects;

/**
 * 消息的VO类
 *
 * @author akita
 * @date 2023/10/17
 */
@Data
@NoArgsConstructor
public class MessageVO {

    private String role;

    private String content;

    public MessageVO(Message message) {
        if (Objects.isNull(message)) {
            return;
        }
        switch (message.getMessageType()) {
            case USER:
                this.role = "user";
                break;
            case ASSISTANT:
                this.role = "assistant";
                break;
            default:
                this.role = "";
                break;
        }
        this.content = message.getText();
    }

}
